#include <bits/stdc++.h>
#define N 1000006
using namespace std;
typedef long long ll;

int T, n, sa[N], len0[N], len1[N], len2[N];
vector <int> eq[N], neq[N];
char ans[N];
bool fndans;

void add (int i, int j) { eq[i].push_back(j); }

void clr ()
{
    fndans=0;
    for (int i=1; i<=n*2; i++) { eq[i].clear(); }
    for (int i=1; i<=n*2; i++) { neq[i].clear(); }
}

bool cmp (const int &x, const int &y)
{
    for (int i=0; i<=min(n-x, n-y); i++) {
        if (ans[x+i]<ans[y+i]) { return 1; }
        if (ans[x+i]>ans[y+i]) { return 0; }
    }
    return x>y;
}

int id[N];

void dfs (int x)
{
    if (x==n+1) {
        for (int i=1; i<=n; i++) { id[i]=i; }
        sort(id+1, id+n+1, cmp);
        for (int i=1; i<=n; i++) if (id[i]!=sa[i]) { return; }

        for (int i=1; i<=n; i++) {
            bool cur=0;
            for (int j=1; j<=i && j<=n-i+1; j++) {
                if (ans[i-j+1]!=ans[i+j-1]) {
                    if (j-1!=len1[i]) { return; }
                    cur=1; break;
                }
            }
            if (!cur) {
                if (min(i, n-i+1)!=len1[i]) { return; }
            }
            if (i<n) {
                cur=0;
                for (int j=1; j<=i && j<=n-i; j++) {
                    if (ans[i-j+1]!=ans[i+j]) {
                        if (j-1!=len2[i]) { return; }
                        cur=1; break;
                    }
                }
                if (!cur) {
                    if (min(i, n-i)!=len2[i]) { return; }
                }
            }
        }
        fndans=1;
        return;
    }
    for (int i=1; i<=n; i++) {
        ans[x]='a'+i-1;
        dfs(x+1);
        if (fndans) { return; }
    }
}

void solveBF ()
{
    dfs(1);

    if (!fndans) { printf("-1\n"); }
    else {
        for (int i=1; i<=n; i++) { printf("%c", ans[i]); } printf("\n");
    }
}

int main ()
{
    freopen("string.in", "r", stdin);
    freopen("string.out", "w", stdout);

    scanf("%d", &T);
    while (T--) {
        scanf("%d", &n);
        for (int i=1; i<=n; i++) { scanf("%d", &sa[i]); sa[i]++; }
        for (int i=1; i<=n*2-1; i++) { scanf("%d", &len0[i]); }

        clr();

        for (int i=1; i<=n*2-1; i+=2) { len1[((i-1)/2)+1]=(len0[i]+1)/2; }
        for (int i=2; i<=n*2-1; i+=2) { len2[i/2]=(len0[i]/2); }

        bool ok=1;

        for (int i=1; i<=n; i++) {
            if (len1[i]>min(i, n-i+1)) { ok=0; }
            if (i<n && len2[i]>min(i, n-i)) { ok=0; }
        }
        if (!ok) { printf("-1\n"); continue; }

        if (n<=8) { solveBF(); continue; }

        int l=0, r=0;
        for (int i=1; i<=n; i++) {
            if (i>r) {
                for (int j=2; j<=len1[i]; j++) { add(i-j+1, i+j-1); }
            }
            else {
                int pos=r+l-i;
                if (pos-len1[pos]+1<=l) {
                    for (int j=(pos-l+1)+1; j<=len1[i]; j++) { add(i-j+1, i+j-1); }
                }
            }
            if (i-len1[i]>=1 && i+len1[i]<=n) { neq[i-len1[i]].push_back(i+len1[i]); }

            if (i+len1[i]-1>=r) { l=i-len1[i]+1; r=i+len1[i]-1; }
        }

        l=0; r=0;
        for (int i=1; i<=n-1; i++) {
            if (i>=r) {
                for (int j=1; j<=len2[i]; j++) { add(i-j+1, i+j); }
            }
            else {
                int pos=(r+l-i-1);
                if (pos-len2[pos]+1<=l) {
                    for (int j=(pos-l+1)+1; j<=len2[i]; j++) { add(i-j+1, i+j); }
                }
            }
            if (i-len2[i]>=1 && i+len2[i]+1<=n) { neq[i-len2[i]].push_back(i+len2[i]+1); }

            if (i+len2[i]>=r) { l=i-len2[i]+1; r=i+len2[i]; }
        }
        
        ans[n]='a';
        for (int i=n-1; i>=1; i--) {
            if (eq[i].size()) { ans[i]=ans[eq[i][0]]; }
            else {
                ans[i]=ans[i+1];
                for (int j=0; j<(int)neq[i].size(); j++) {
                    int pos=neq[i][j];
                    if (ans[i]<(ans[pos]+1)) { ans[i]=(ans[pos]+1); }
                }
            }
        }

        for (int i=1; i<=n; i++) {
            for (int j=0; j<(int)eq[i].size(); j++) {
                int pos=eq[i][j];
                if (ans[i]!=ans[pos]) { ok=0; break; }
            }
            for (int j=0; j<(int)neq[i].size(); j++) {
                int pos=neq[i][j];
                if (ans[i]==ans[pos]) { ok=0; break; }
            }
            if (i<n && ans[i]<ans[i+1]) { ok=0; break; }
        }

        if (!ok) { printf("-1\n"); }
        else {
            for (int i=1; i<=n; i++) { printf("%c", ans[i]); } printf("\n");
        }
    }

    return 0;
}